package com.hzc.springchan.service.impl;

import com.hzc.springchan.constant.System;
import com.hzc.springchan.enums.CMessageInfo;
import lombok.Getter;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 消息推送服务实现类
 * @author chen990627
 * @date 2022/10/19
 */
@Service
@Async(System.Executor.TASK_EXECUTOR)
public class AsyncOperationService {

    @Getter
    public static class Super {

        private String transactionId;

        public void setTransactionId(String transactionId) {
            this.transactionId = transactionId;
        }
    }

    /**
     * 消息推送请求体类
     */
    @Getter
    public static class CMessage extends Super {

        Integer receiver;

        CMessageInfo messageInfo;

        Object[] formatParams;

        public CMessage() {
        }

        public CMessage receiver(Integer receiver) {
            this.receiver = receiver;
            return this;
        }

        public CMessage info(CMessageInfo messageInfo) {
            this.messageInfo = messageInfo;
            return this;
        }

        public CMessage params(Object... params) {
            this.formatParams = params;
            return this;
        }
    }
}
